﻿<%@ Page Title="" Language="C#" MasterPageFile="~/General.Master" AutoEventWireup="true" CodeBehind="Home_Profile.aspx.cs" Inherits="NCAB.WF.Home_Profile" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>NetCorp | Profile</title>

    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet" />

    <script>
        function GetUsuario_ByUserName(UserName, WSUser, WSPass) {
            
            $.ajax({
                crossDomain: true,
                type: "POST",
                url: "services/WS_User.asmx/GetUsuario_ByUserName",
                data: "{'UserName':'" + UserName + "', 'WSUser':'" + WSUser + "', 'WSPass':'" + WSPass + "'}",
                contentType: "application/json; charset=UTF-8",
                dataType: "json",
                success: function (data) {
                    
                    var resultado = $.parseJSON(data.d);

                    if (resultado != null) {
                        $('[id$=lbNombreCompleto]').text(resultado.Nombres + " " + resultado.Apellidos);
                        $('[id$=lbDireccionEmpresa]').text(" " + resultado.Direccion);
                        $('[id$=lbAboutMe]').text(resultado.AboutMe);
                        $('[id$=txtNombres]').val(resultado.Nombres);
                        $('[id$=txtApellidos]').val(resultado.Apellidos);
                        $('[id$=txtEmail]').val(resultado.Email);
                        $('[id$=txtIdentificacion]').val(resultado.Identificacion);
                        $('[id$=txtMovil]').val(resultado.TMovil);
                        $('[id$=txtOficina]').val(resultado.TOficina);
                        $('[id$=txtDireccion]').val(resultado.Direccion);
                        $('[id$=txtAboutMe]').val(resultado.AboutMe);

                    }
                    else {
                        location.href = "Error.aspx";
                    }
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    location.href = "Error.aspx";
                }
            });
        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-lg-10">
            <h2>Profile</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="Home.aspx">Home</a>
                </li>
                <li class="active">
                    <strong>Profile</strong>
                </li>
            </ol>
        </div>
        <div class="col-lg-2">
        </div>
    </div>

    <div class="wrapper wrapper-content">
        <div class="row animated fadeInRight">
            <div class="col-md-4">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>
                            <asp:Label ID="lbNombreCompleto" runat="server"></asp:Label>
                        </h5>
                    </div>
                    <div>
                        <div class="ibox-content profile-content">
                            <div class="text-center">
                                <img id="imgProfileDetail" runat="server" alt="image" src="img/profile.jpg">
                            </div>
                            <br />
                            <p>
                                <i class="fa fa-map-marker"></i>
                                <asp:Label ID="lbDireccionEmpresa" runat="server"></asp:Label>
                            </p>
                            <h5>About me
                            </h5>
                            <p>
                                <asp:Label ID="lbAboutMe" runat="server"></asp:Label>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-8">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>More Details</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">Nombres</label>

                                <div class="col-sm-10">
                                    <asp:TextBox ID="txtNombres" class="form-control" runat="server" placeholder="Nombres" required></asp:TextBox>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">Apellidos</label>

                                <div class="col-sm-10">
                                    <asp:TextBox ID="txtApellidos" class="form-control" runat="server" placeholder="Apellidos" required></asp:TextBox>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">E-mail</label>
                                <div class="col-sm-10">
                                    <asp:TextBox ID="txtEmail" disabled="" runat="server" type="email" class="form-control" placeholder="E-mail" required></asp:TextBox>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">Identificación</label>
                                <div class="col-sm-10">
                                    <asp:TextBox ID="txtIdentificacion" class="form-control" runat="server" placeholder="Identificación" required></asp:TextBox>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">Móvil</label>
                                <div class="col-sm-10">
                                    <asp:TextBox ID="txtMovil" class="form-control" type="number" runat="server" placeholder="Móvil" required></asp:TextBox>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">Oficina</label>
                                <div class="col-sm-10">
                                    <asp:TextBox ID="txtOficina" class="form-control" type="number" runat="server" placeholder="Oficina" required></asp:TextBox>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">Dirección</label>
                                <div class="col-sm-10">
                                    <asp:TextBox ID="txtDireccion" class="form-control" runat="server" placeholder="Dirección" required></asp:TextBox>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">About Me</label>
                                <div class="col-sm-10">
                                    <asp:TextBox ID="txtAboutMe" class="form-control" runat="server" placeholder="AboutMe" TextMode="MultiLine" required></asp:TextBox>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <asp:Button ID="btnSaveChanges" class="btn btn-primary" UseSubmitBehavior="true" type="submit" runat="server" Text="Save Changes" OnClick="btnSaveChanges_Click"></asp:Button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="js/plugins/sweetalert/sweetalert.min.js"></script>

    <script>
        try {

            $('[id$=btnSaveChanges]').click(function (event) {
            swal({
                title: "¿Estás seguro de actualizar?",
                text: "Con esta acción actualizará su perfil.",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "OK!",
                cancelButtonText: "Cancel!",
                closeOnConfirm: false,
                closeOnCancel: false
            },
                function (isConfirm)
                {
                    if (isConfirm) {
                        __doPostBack('<%= btnSaveChanges.UniqueID %>', '');
                    }
                    else {
                        swal("Cancelado", "La acción fue cancelada.", "error");
                    }
                }
            );
            event.preventDefault();            
        });

        } catch (e) {
            alert(e);
            location.href = "Error.aspx";
        }
        

        function mensaje_exito() {
            swal("¡OK!", "Usuario actualizado correctamente.", "success");
        }
    </script>
</asp:Content>
